// pages/ticket/car_ticket.js
var app = getApp();
var Util= require('../../utils/util.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    parameter: {
      'navbar': '1',
      'return': '0',
      'title':'我的票据'
    },
    productRefound: {},
    todayTicket:[],
    tuanTicket:[],
    scenicTicket:[],
    selectIndex: '',
    ending_period_list: [],
    running_period_list: [],
    scrollViewHeight: wx.getSystemInfoSync().windowHeight,
    navH: "",
    isHideMes: !0,

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  attached: function () {
    this.setData({
      navH: app.globalData.navHeight
    });
  },
  showMessage: function(e) {
    // this.getProductRefound();
    console.log(e)
     this.setData({
        isHideMes: !1,
        productRefound: {
          title: e.target.dataset.item.productInfo.store_name,
          over_time: e.target.dataset.date,
          kefu_phone: e.target.dataset.kefu,
          qr_code:  e.target.dataset.qrcode,
          code:  e.target.dataset.code,
        }
    });
   },
  get_today_ticket:function(){
    var that = this;
    app.baseGet(app.U({ c: 'auth_api', a:'get_today_ticket'}),function(res){
      that.setData({todayTicket:res.data});
    });
  },
  get_tuan_ticket:function(){
    var that = this;
    app.baseGet(app.U({ c: 'auth_api', a:'get_tuan_ticket'}),function(res){
      that.setData({tuanTicket:res.data});
    });
  },
  get_scenic_ticket:function(){
    var that = this;
    app.baseGet(app.U({ c: 'auth_api', a:'get_scenic_ticket'}),function(res){
      that.setData({scenicTicket:res.data});
    });
  },
  onVailTicket: function onVailTicket(e) {
    var dataset = e.currentTarget.dataset;
    wx.navigateTo({
        url: "/pages/vail_ticket/vail_ticket?orderId="+dataset.orderid
    });
},
tuanFailed: function tuanFailed(e) {
  app.Tips({ title:'拼团失败，请勿验票'});
},
animationfinish: function(t) {
  var scrollHeight = 600;
  if(0 == this.data.selectIndex){
    if(this.data.todayTicket.length > 0 ){
      scrollHeight = 400 * this.data.todayTicket.length
    }
  }
  if(1 == this.data.selectIndex){
    if(this.data.scenicTicket.length > 0 ){
      scrollHeight = 600 * this.data.scenicTicket.length
    }
  }
  if(2 == this.data.selectIndex){
    if(this.data.tuanTicket.length > 0 ){
      scrollHeight = 400 * this.data.tuanTicket.length
    }
  }
  this.setData({
      scrollViewHeight: scrollHeight
  });
},
swiperChange: function(t) {
  this.setData({
      selectIndex: t.detail.current
  });
},
btnClick: function(t) {
  this.setData({
      selectIndex: t.currentTarget.id
  });
},
goHere: function goHere(e) {
  var obj = e.currentTarget.dataset;
  wx.openLocation({
      //​使用微信内置地图查看位置。
      latitude: Number(obj.lat),
      longitude: Number(obj.lng),
      name: obj.name
  });
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 授权回调
  */
  onLoadFun:function(){
    if(app.globalData.isLog && app.globalData.token) {
      this.get_today_ticket();
      this.get_tuan_ticket();
      this.get_scenic_ticket();
    }
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({
      selectIndex: app.globalData.ticket_type
  });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.get_today_ticket();
      this.get_tuan_ticket();
      this.get_scenic_ticket();
    wx.stopPullDownRefresh()
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})